Learn R Programming

chronosphere (version 0.4.1)

[[,XArray,ANY,ANY-method: Indexing to extract RasterLayers of a RasterArray or Spatial* of a SpatialArray object

Description

Double bracket '[[' refers to layers' name in the RasterStack of the RasterArray or the SpatialStack of the SpatialArray. Use single brackets to extract elements based on their position in the RasterArray or SpatialArray

Usage

# S4 method for XArray,ANY,ANY
[[(x, i, drop = TRUE)

Value

A RasterLayer or RasterArray class object.

Arguments

x

RasterArray or SpatialArray object.

i

subscript of the first dimension(rows) or vector-like subsetting.

drop

logical should the RasterStack be dropped and the element be reduced to a single RasterLayer?

Examples

Run this code
data(dems)
# finds a layer
dems[["dem_30"]]
# returns a stack
dems[[c("dem_0", "dem_15")]]
# replaces a layervalues, but not the attributes of the layer
dem2 <- dems
dem2[["dem_0"]] <- dem2[["dem_5"]]
# compare every value in the 0 and 5 ma maps, they are all the same
mean(values(dem2[["dem_0"]]==dem2[["dem_5"]]))

Run the code above in your browser using DataLab